package com.app.extended_plugin;

import android.app.Activity;
import android.util.Log;

import com.app.extended_plugin.utlis.NetInfoManager;

import io.flutter.plugin.common.EventChannel;

public class NetworkEventHandler implements EventChannel.StreamHandler{

    private Activity activity;
    private EventChannel.EventSink eventSink;
    private NetInfoManager manager;
    private static final String TAG = "NetworkEventHandler";

    public NetworkEventHandler(Activity activity) {
        this.activity = activity;
        manager = NetInfoManager.newInstance(activity);
    }

    @Override
    public void onListen(Object arguments, EventChannel.EventSink events) {
        eventSink = events;
        String data = manager.getNetWork(activity);
        events.success(data);

    }

    @Override
    public void onCancel(Object arguments) {

    }

    private void onAttachedActivity(){
        Log.i(TAG, "onAttachedToActivity:a "+Thread.currentThread().getName());

    }
}
